package com.chis.jxc;

import com.chis.jmdatatimer.comm.TxMgmtModule;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

public class GjData {

    public static void main(String[] args) {
        try {
            String path = args[0];
            String opt = args[1];
            String bat = args[2];

//            String path = "C:\\Users\\wlj\\Desktop\\tt";
//            String opt = "09";
//            String bat = "56";
            File file = new File(path);
            File[] fs = file.listFiles();	//遍历path下的文件和目录，放在File数组中
            for(File file1:fs){					//遍历File[]数组
                
                FileReader m  = new FileReader(file1);
                BufferedReader reader = new BufferedReader(m);
                String ckcode = "";
                String ckdate = "";
                String ckunit = "";
                String cktype = "";
                String ymname = "";
                String ymbact = "";
                String ymnum = "";
                String pernum = "";
                while (true) {
                    String nextline  = reader.readLine();
                    if (nextline == null) {
                        break;
                    }
//                System.out.println(nextline);
                    if(nextline.contains("OrderOutCode")){
                        ckcode = nextline.substring(nextline.indexOf(">")+21,nextline.lastIndexOf("<"));
                    }
                    if(nextline.contains("VacOutDate")){
                        ckdate = nextline.substring(nextline.indexOf(">")+1,nextline.lastIndexOf("<"));
                    }
                    if(nextline.contains("VacOutSource")){
                        ckunit = nextline.substring(nextline.indexOf("value=")+7,nextline.indexOf(">")-1);
                    }
                    if(nextline.contains("VacOutOrderTypeCode")){
                        cktype = nextline.substring(nextline.indexOf("value=")+7,nextline.indexOf(">")-1);
                    }

                    if(nextline.contains("VacNameCode")){
                        ymname = nextline.substring(nextline.indexOf("value=")+7,nextline.indexOf(">")-1);
                    }
                    if(nextline.contains("BatchNumber")){
                        ymbact = nextline.substring(nextline.indexOf(">")+1,nextline.lastIndexOf("<"));
                    }
                    if(nextline.contains("VacOutAmount")){
                        ymnum = nextline.substring(nextline.indexOf(">")+1,nextline.lastIndexOf("<"));
                    }
                    if(nextline.contains("PersonNum")){
                        pernum = nextline.substring(nextline.indexOf(">")+1,nextline.lastIndexOf("<"));
                    }

                    if(nextline.contains("</VaccInfo>") && cktype.equals(opt) && ymname.startsWith(bat)){
                        System.out.println(ckcode+"\t"+ckdate+"\t"+ckunit+"\t"+ymname+"\t"+ymbact+"\t"+ymnum+"\t"+pernum);
                    }
                }
                reader.close();

            }



        } catch (Exception e){
            e.printStackTrace();
        }


    }
}
